﻿package game
{
	import flash.display.MovieClip;
	import flash.display.SimpleButton;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	import game.events.EventData;
	/**
	 * ...
	 * @author Doan Nguyen Thuy Nha Truc (Bamboo)	
	 */
	public class GameMenuPanel extends MovieClip
	{
		public var roulleteBtn:SimpleButton;
		public var dragonBtn:SimpleButton;
		public var bacaratBtn:SimpleButton;
		public var sicboBtn:SimpleButton;
		public var bacInsBtn:SimpleButton;
		
		public var accountInfoBtn:SimpleButton;
		public var lobbyBtn:SimpleButton;
		public var betStatusBtn:SimpleButton;
		public var gameHistoryBtn:SimpleButton;
		public var gameRuleBtn:SimpleButton;
		public var supportBtn:SimpleButton;
		
			
		public var roulleteTf:TextField;
		public var dragonTf:TextField;
		public var bacaratTf:TextField;
		public var sicboBtnTf:TextField;
		public var bacInsBtnTf:TextField;
		
		public var accountInfoTf:TextField;
		public var lobbyTf:TextField;
		public var betStatusTf:TextField;
		public var gameHistoryTf:TextField;
		public var gameRuleTf:TextField;
		public var supportTf:TextField;

		private var arrayLableBtn:Array;
		private var arrayBtn:Array;
		private var overColor:Number = 0xFFCC00;
		private var outColor:Number = 0xFFFFFF;
		
		public function GameMenuPanel() 
		{
			arrayLableBtn = new Array(roulleteTf, dragonTf, bacaratTf, sicboBtnTf, bacInsBtnTf, accountInfoTf, lobbyTf, betStatusTf, gameHistoryTf, gameRuleTf, supportTf);
			arrayBtn = new Array(roulleteBtn, dragonBtn, bacaratBtn, sicboBtn, bacInsBtn, accountInfoBtn, lobbyBtn, betStatusBtn, gameHistoryBtn, gameRuleBtn, supportBtn);
			var leng:int = arrayBtn.length;
			for (var i:int = 0; i < leng; i++ )
			{
				arrayBtn[i].addEventListener(MouseEvent.CLICK, hdlBtnClick);
				arrayBtn[i].addEventListener(MouseEvent.ROLL_OVER, hdlBtnRollOver);
				arrayBtn[i].addEventListener(MouseEvent.ROLL_OUT, hdlBtnRollOut);
			}
		
			
		}
		
		/**
		 * @author Bamboo
		 * @param	e
		 */
		private function hdlBtnClick(e:MouseEvent):void
		{
			trace("anem:" + e.currentTarget.name);
			//sendInfoMainGame(e.currentTarget.name);
			
			var event:EventData = new EventData(EventData.SET_MENU_GAME, true);
			event.ms = e.currentTarget.name;
			dispatchEvent(event);
			
		}
		/**
		 * @author	Bamboo
		 * @param	e
		 */
		private function hdlBtnRollOver(e:MouseEvent):void
		{
			
			var leng:int = arrayBtn.length;
			for (var i:int = 0; i < leng; i++ )
			{
				if (arrayBtn[i] == e.currentTarget)
				{
					arrayLableBtn[i].textColor = overColor;
					break;
				}
			}
		
			
		}
		/**
		 * @author	Bamboo
		 * @param	e
		 */
		private function hdlBtnRollOut(e:MouseEvent):void
		{
			var leng:int = arrayBtn.length;
			for (var i:int = 0; i < leng; i++ )
			{
				if (arrayBtn[i] == e.currentTarget)
				{
					arrayLableBtn[i].textColor = outColor;
					break;
				}
			}
		}
		
		/**
		 * @author Bamboo
		 * @param	e
		 */
		public function sendInfoMainGame(nameObj:String):void {
			MovieClip(parent).receiverInfoFromMenu(nameObj);
			//trace("ok");
		}
		
	}

}